5134b44ff5ea3c3b542371870c9fdb76120f7b70,server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java,ClusteredAgentManagerImpl,scanDirectAgentToLoad,#,164
Before Change
Long clusterId = hosts.get((int) (_loadSize - 1)).getClusterId();
if (clusterId != null) {
for (int i = (int) (_loadSize - 1); i > 0; i--) {
if (hosts.get(i).getClusterId() == clusterId) {
hosts.remove(i);
} else {
break;
After Change
List<HostVO> hosts = _hostDao.findDirectAgentToLoad(cutSeconds, _loadSize);
if (hosts != null && hosts.size() == _loadSize) {
//if list contains more than one cluster, exclude the last cluster from the list
if (hosts.size() > 1 && hosts.get(0).getClusterId().longValue() != hosts.get(hosts.size()-1).getClusterId().longValue()) {
Long clusterId = hosts.get((int) (_loadSize - 1)).getClusterId();
if (clusterId != null) {
for (int i = (int) (_loadSize - 1); i > 0; i--) {
if (hosts.get(i).getClusterId().longValue() == clusterId.longValue()) {
hosts.remove(i);
} else {
break;